package game.mapEditor;

import processing.core.*; 

public class WsAppletMapEditor extends PApplet {

	private static final long serialVersionUID = 909612209036547407L;
	
	private MapInEdition tm;
	DrawFunctions funct;
	
	@Override
	public void setup() {
		
		size(600, 600);
		smooth();
		
	}

	@Override
	public void draw() {
		background(0);
		funct.translate();
		tm.drawBackground();
		funct.draw();
		tm.draw();
		funct.drawExtra();
	}

	@Override
	public void keyPressed() {
		funct.keyPressed();
	}
	
	public void mousePressed() {
		funct.mousePressed();
//		if (!iAmMighty)
//			return;
//		tm.drag();
	}
	
//	public void mouseDragged() {
//		
//	}
	
	public void mouseReleased() {
		funct.mouseReleased();
//		if (!iAmMighty)
//			return;
//		tm.drop();
	}
	
	static public void main(String args[]) {
		PApplet.main(new String[] { "--bgcolor=#F0F0F0", "WsMap" });
	}
	
	static public void wsInit() {
		PApplet.main(new String[] { "--bgcolor=#F0F0F0", "game.map.WsApplet" });
	}

	public void loadMap(String path) {
		tm = new MapInEdition(this);
		tm.load(path);
		funct = new DrawFunctions(this);
		funct.setMap(tm);
	}
	
	public DrawFunctions getDrawFunctions() {
		return funct;
	}

	public void newMap(String size) {
		tm = new MapInEdition(this, size);
		funct = new DrawFunctions(this);
		funct.setMap(tm);
	}
	
	/**
	 * Width e height fixos para encaixar na imagem de fundo.
	 */
	@Override
	public int getWidth() {
		return 600;
	}
	@Override
	public int getHeight() {
		return 600;
	}
	
}

